package com.fesine.ch01.lesson02;

/**
 * 运行MyThread类，同时自身也调起线程
 * Created by Fesine on 2016/6/26.
 */
public class Test {
    public static void main(String[] args) {
        //在main中运行的为主线程，线程名为main
        MyThread myThread = new MyThread();
        myThread.setName("myThread");
        myThread.start();
        for (int i = 0; i < 10; i++) {
            int time = (int) (Math.random() * 1000);
            try {
                Thread.sleep(time);
                System.out.println("main() = " + Thread.currentThread().getName());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
